"""
    姓名 :  新  哥
    时间 : 2022/6/29 上午 09:28
    文件名 : recharge_api.py
    需求：
    
"""
import logging

from config import BASE_HOST


class RechargeApi:
    """封装充值类接口"""

    def __init__(self, session):
        # 创建session对象
        self.session = session

    def recharge_verify(self, r):
        """封装充值验证码接口"""
        url = BASE_HOST + "/common/public/verifycode/{}".format(r)
        resp = self.session.get(url=url)
        logging.info("获取充值获取验证码接口的响应状态码：{}".format(resp.status_code))
        return resp

    def recharge(self, amount, reForm, paymentType='chinapnrTrust', formStr='reForm'):
        """封装充值接口"""
        url = BASE_HOST + "/trust/trust/recharge"
        form_dict = {"paymentType": paymentType, "amount": amount, "formStr": formStr, "valicode": reForm}
        resp = self.session.post(url=url, data=form_dict)
        logging.info("获取充值接口的响应数据:{}".format(resp.json()))
        return resp

    def third_open_recharge(self, url, form_dict):
        """封装第三方充值接口"""
        resp = self.session.post(url=url, data=form_dict)
        logging.info("获取第三方充值接口返回得响应数据：{}".format(resp.text))
        return resp
